package org.wedding.center.controller;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.wedding.utils.CommonResult;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.AllArgsConstructor;
import org.wedding.dto.PageModel;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMethod;
import java.util.List;

import org.wedding.center.service.ServiceTypeService;
import org.wedding.center.entity.ServiceType;
import org.wedding.center.dto.query.ServiceTypeQuery;

/**
 * 服务类别表(wedding) 表控制层
 *
 * @author 2025-07-05 19:35:45
 * @since sky
 */
@AllArgsConstructor
@RestController
@RequestMapping("/serviceTypeInfo")
@Tag(name = "ServiceType", description = "服务类别表")
public class ServiceTypeController {
    private final ServiceTypeService serviceTypeService;


    @GetMapping("list")
    @Operation(summary="查询服务类别表")
    public CommonResult list(ServiceTypeQuery query) {
        return serviceTypeService.findAll(query);
    }

    /**
     * 通过主键查询单条数据
     *
     * @param id 主键
     * @return 单条数据
     */
    @Operation(summary = "通过主键查询单条数据")
    @RequestMapping(value = "/view", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult view(String id) {
        return serviceTypeService.view(id);
    }

    /**
     * 新增数据
     *
     * @param serviceType 实体对象
     * @return 新增结果
     */
    @Operation(summary = "新增数据")
    @RequestMapping(value = "/add", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult add(@RequestBody ServiceType serviceType) {
        return serviceTypeService.add(serviceType);
    }

    /**
     * 修改数据
     *
     * @param serviceType 实体对象
     * @return 修改结果
     */
    @Operation(summary = "修改数据")
    @RequestMapping(value = "/update", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult update(@RequestBody ServiceType serviceType) {
        return serviceTypeService.updateEntity(serviceType);
    }

    /**
      * 删除数据
      *
      * @param ids 主键
      * @return 删除结果
      */
    @Operation(summary = "删除数据")
    @RequestMapping(value = "/delete", method = {RequestMethod.POST, RequestMethod.GET}, produces = "application/json; charset=UTF-8")
    public CommonResult delete(@RequestBody List<String> ids) {
        return serviceTypeService.delete(ids);
    }

}